/* -----------------------------------------------------------------------------
 * PROJECT    : lwf_handlers
 * FILE       : FontUtil.java
 *
 * HISTORY:
 * Date          Author                        Description
 * ----------------------------------------------------------------------------- 
 * Feb 8, 2011  mycodetalks			       Created
 */
package net.lwf.pdf.util;

import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Font;
import com.itextpdf.text.FontFactory;

public class FontUtil {
	
	private static final String DEFAULT_FONT_FAMILY = FontFactory.TIMES_ROMAN;
	private static final int DEFAULT_FONT_SIZE = 20;
	private static final int DEFAULT_FONT_WEIGHT = Font.NORMAL;
	private static final BaseColor DEFAULT_FONT_COLOR = new BaseColor(0, 0, 0);

	/**
	 * Gets the display font. In this, defalut values are considered for
	 * the font family, font color, font size and font weight.
	 * 
	 * Default font family : FontFactory.TIMES_ROMAN 
	 * Default font color  : new BaseColor(0, 0, 0)
	 * Default font size   : 20
	 * Default font weight : Font.NORMAL
	 * 
	 * @param fontFamily		Chosen font family
	 * @return
	 */	
	public static Font getDisplayFont() {
		return getDisplayFont(DEFAULT_FONT_FAMILY);
	}
	
	/**
	 * Gets the display font. In this, defalut values are considered for
	 * the font color, font size and font weight.
	 * 
	 * Default font color  : new BaseColor(0, 0, 0)
	 * Default font size   : 20
	 * Default font weight : Font.NORMAL
	 * 
	 * @param fontFamily		Chosen font family
	 * @return
	 */	
	public static Font getDisplayFont(String fontFamily) {
		return getDisplayFont(fontFamily, DEFAULT_FONT_SIZE);
	}
	
	/**
	 * Gets the display font. In this, defalut values are considered for
	 * the font family, font color and font weight.
	 * 
	 * Default font family : FontFactory.TIMES_ROMAN
	 * Default font color  : new BaseColor(0, 0, 0)
	 * Default font weight : Font.NORMAL
	 * 
	 * @param fontsize		Chosen font size (a number)
	 * @return
	 */	
	public static Font getDisplayFont(int fontSize) {
		return getDisplayFont(DEFAULT_FONT_FAMILY, fontSize);
	}
	
	/**
	 * Gets the display font. In this, defalut values are considered for
	 * the font color and font weight.
	 * 
	 * Default font color  : new BaseColor(0, 0, 0)
	 * Default font weight : Font.NORMAL
	 * 
	 * @param fontFamily	Chosen font famlily (from FontFactory.)
	 * @param fontsize		Chosen font size (a number)
	 * @return
	 */	
	public static Font getDisplayFont(String fontFamily, int fontsize) {
		return getDisplayFont(fontFamily, fontsize, DEFAULT_FONT_WEIGHT);
	}
	
	/**
	 * Gets the display font. In this, defalut font color is considered.
	 * 
	 * Default font color  : new BaseColor(0, 0, 0)
	 * 
	 * @param fontFamily	Chosen font famlily (from FontFactory.)
	 * @param fontsize		Chosen font size (a number)
	 * @param fontWeight	Chosen font weight (from Font.)
	 * @return
	 */	
	public static Font getDisplayFont(String fontFamily, int fontsize, int fontWeight) {
		return getDisplayFont(fontFamily, fontsize, fontWeight, DEFAULT_FONT_COLOR);
	}
	
	/**
	 * Gets the display font.
	 * 
	 * @param fontFamily	Chosen font famlily (from FontFactory.)
	 * @param fontsize		Chosen font size (a number)
	 * @param fontWeight	Chosen font weight (from Font.)
	 * @param fontColor		Chosen font color (from BaseColor)
	 * @return
	 */
	public static Font getDisplayFont(String fontFamily, int fontsize, int fontWeight,  BaseColor fontColor) {
		String _fontFamily = fontFamily;
		int _fontSize = fontsize;
		int _fontWeight = fontWeight;
		BaseColor _fontColor = fontColor;
		
		if(fontFamily == null) {
			_fontFamily = DEFAULT_FONT_FAMILY;
		}
		if(_fontSize == 0) {
			_fontSize = DEFAULT_FONT_SIZE;
		}
		if(_fontWeight == 0) {
			_fontWeight = DEFAULT_FONT_WEIGHT;
		}
		if(_fontColor == null) {
			_fontColor = DEFAULT_FONT_COLOR;
		}
		return FontFactory.getFont(_fontFamily, _fontSize, _fontWeight, _fontColor);
	}
	
	
	/**
	 * Gets the bolded display font. In this, defalut values are considered for
	 * the font family, font color, font size and font weight.
	 * 
	 * Default font family : FontFactory.TIMES_ROMAN 
	 * Default font color  : new BaseColor(0, 0, 0)
	 * Default font size   : 20
	 * Default font weight : Font.NORMAL
	 * 
	 * @param fontFamily		Chosen font family
	 * @return
	 */	
	public static Font getBoldedDisplayFont() {
		return getDisplayFont(DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, Font.BOLD);
	}
	
	/**
	 * Gets the bolded display font. In this, defalut values are considered for
	 * the font color, font size and font weight.
	 * 
	 * Default font color  : new BaseColor(0, 0, 0)
	 * Default font size   : 20
	 * Default font weight : Font.NORMAL
	 * 
	 * @param fontFamily		Chosen font family
	 * @return
	 */	
	public static Font getBoldedDisplayFont(String fontFamily) {
		return getDisplayFont(fontFamily, DEFAULT_FONT_SIZE, Font.BOLD);
	}
	
	/**
	 * Gets the bolded display font. In this, defalut values are considered for
	 * the font family, font color and font weight.
	 * 
	 * Default font family : FontFactory.TIMES_ROMAN
	 * Default font color  : new BaseColor(0, 0, 0)
	 * Default font weight : Font.NORMAL
	 * 
	 * @param fontsize		Chosen font size (a number)
	 * @return
	 */	
	public static Font getBoldedDisplayFont(int fontSize) {
		return getDisplayFont(DEFAULT_FONT_FAMILY, fontSize, Font.BOLD);
	}
	
	/**
	 * Gets the bolded display font. In this, defalut values are considered for
	 * the font color and font weight.
	 * 
	 * Default font color  : new BaseColor(0, 0, 0)
	 * Default font weight : Font.NORMAL
	 * 
	 * @param fontFamily	Chosen font famlily (from FontFactory.)
	 * @param fontsize		Chosen font size (a number)
	 * @return
	 */
	public static Font getBoldedDisplayFont(String fontFamily, int fontSize) {
		return getDisplayFont(fontFamily, fontSize, Font.BOLD);
	}
	
	public static Font getCellHeaderFont() {
		return getDisplayFont(26);
	}
	
	public static Font getCellFont() {
		return getDisplayFont(24);
	}
	
	public static Font getQuestionNumberFont() {
		return getDisplayFont(FontFactory.TIMES_ROMAN, 16, Font.BOLD, BaseColor.RED);
	}
	
	
} //FontUtil



